package org.geektimes.projects.user.web.listener;


import org.geektimes.dependency.injection.web.context.ClassicComponentContext;
import org.geektimes.dependency.injection.web.context.ComponentContext;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.util.logging.Logger;


/**
 * {@link ComponentContext} 初始化器
 * 与 ContextLoaderListener 相识
 */
public class ComponentContextInitializerListener implements ServletContextListener {
    private final Logger logger = Logger.getLogger(getClass().getName());

    private ServletContext servletContext;





    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        logger.info("===================== start ComponentContextInitializerListener contextInitialized method =====================");

        servletContext = servletContextEvent.getServletContext();

        ClassicComponentContext classicComponentContext = new ClassicComponentContext();
        classicComponentContext.init(servletContext);
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
//        ComponentContext componentContext = ClassicComponentContext.getInstance();
//        componentContext.destroy();
    }


}
